import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Task1 {
	
	public static void main(String[] args) {
		
		Scanner inputCS = new Scanner(System.in);
		
		String input = inputCS.nextLine();
		List<String> list = new ArrayList<String>();
		
		while (!input.equals("End")) {
			
			list.add(input);
			input = inputCS.nextLine();
		}
		
		int beers = 0;
		
		for (int i = 0; i < list.size(); i++) {
			
			String[] array = new String[2];
			array = list.get(i).split(" ");
			
			if (array[1].equals("stacks")) {
				
				beers += Integer.parseInt(array[0]) * 20;
			}
			else {
				
				beers += Integer.parseInt(array[0]);
			}
		}
		
		int stacksResult = beers / 20;
		int beersResult = beers % 20;
		
		System.out.println(stacksResult + " stacks + " + beersResult + " beers");
	}
}